import 'package:flutter/material.dart';
import 'package:fluttertoast/fluttertoast.dart';
import 'package:musician_flutter/gen/assets.gen.dart';
import 'package:musician_flutter/generated/l10n.dart';
import 'package:musician_flutter/ui/theme/theme.dart';
import 'package:musician_flutter/ui/widgets/ShareOption.dart';
import 'package:musician_flutter/ui/widgets/image_view.dart';

class ShareDialog extends StatelessWidget {
  const ShareDialog({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Container(
      height: 155,
      decoration: BoxDecoration(
        color: AppTheme.colorBackgroundSecondaryDark,
        borderRadius: BorderRadius.vertical(top: Radius.circular(16)),
      ),
      child: Column(
        mainAxisAlignment: MainAxisAlignment.spaceBetween,
        crossAxisAlignment: CrossAxisAlignment.start,
        children: [
          Padding(
            padding: const EdgeInsets.only(top: 12, left: 15),
            child: Text(
              'Share as image',
              style: TextStyle(fontSize: 14, fontWeight: FontWeight.bold, color: Colors.white),
            ),
          ),
          Expanded(
            child: SingleChildScrollView(
              scrollDirection: Axis.horizontal,
              child: Row(
                children: [
                  ShareOption(
                    title: S.current.textInstagramStories,
                    imagePath: Assets.images.iconInstagram.path,
                    onTap: () {
                      Fluttertoast.showToast(msg: "Instagram\nStories");
                    },
                  ),
                  ShareOption(
                    title: S.current.textFacebookStories,
                    imagePath: Assets.images.iconShareFacebook.path,
                    onTap: () {
                      Fluttertoast.showToast(msg: "Facebook\nStories");
                    },
                  ),
                  ShareOption(
                    title: S.current.textFacebook,
                    imagePath: Assets.images.iconFacebook.path,
                    onTap: () {
                      Fluttertoast.showToast(msg: "Facebook");
                    },
                  ),
                  ShareOption(
                    title: S.current.textMessenger,
                    imagePath: Assets.images.iconMessenger.path,
                    onTap: () {
                      Fluttertoast.showToast(msg: "Messenger");
                    },
                  ),
                  ShareOption(
                    title: S.current.textZaloChat,
                    imagePath: Assets.images.iconZalo.path,
                    onTap: () {
                      Fluttertoast.showToast(msg: "Zalo\nChat");
                    },
                  ),
                  ShareOption(
                    title: S.current.textTelegram,
                    imagePath: Assets.images.iconTelegram.path,
                    onTap: () {
                      Fluttertoast.showToast(msg: "Telegram");
                    },
                  ),
                  ShareOption(
                    title: S.current.textCopy,
                    imagePath: Assets.images.iconShareCopyLink.path,
                    onTap: () {
                      Fluttertoast.showToast(msg: "Copy");
                    },
                  ),
                  ShareOption(
                    title: S.current.textOthers,
                    imagePath: Assets.images.iconShareOthers.path,
                    onTap: () {
                      Fluttertoast.showToast(msg: "Others");
                    },
                  ),
                  SizedBox(
                    width: 15,
                  )
                ],
              ),
            ),
          ),
        ],
      ),
    );
  }

  Widget _buildShareOption(String title, String imagePath, VoidCallback onTap) {
    return GestureDetector(
      onTap: onTap,
      child: Container(
        height: 104,
        margin: EdgeInsets.only(left: 15, top: 8),
        child: Column(
          mainAxisSize: MainAxisSize.min,
          children: [
            Container(
              width: 48,
              height: 48,
              decoration: BoxDecoration(
                shape: BoxShape.circle,
              ),
              child: ImageView(imagePath),
            ),
            SizedBox(height: 8),
            Text(
              title,
              style: TextStyle(fontSize: 12, color: Colors.white),
              textAlign: TextAlign.center,
            ),
          ],
        ),
      ),
    );
  }
}
